﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WindowsApp.QLMonHoc;
using WindowsApp.QLGiaoVien;
using WindowsApp.QLTaiKhoan;
using WindowsApp.QLLopHoc;
using WindowsApp.QLThoiKhoaBieuDN;
using WindowsApp.QLKeHoachGiangDay;
using Entities;

namespace WindowsApp
{
    public partial class frmFormChuongTrinh :DevComponents.DotNetBar.Office2007RibbonForm
    {
        public TaiKhoan _tk;   
        public frmFormChuongTrinh()
        {
            InitializeComponent();
        }
        public frmFormChuongTrinh(TaiKhoan tk):base()
        {
            _tk = tk;
            
        }
        private void btnExpand_Click(object sender, EventArgs e)
        {
            if (ribbonControl.Expanded)
            {
                ribbonControl.Expanded = false;
                btnExpand.Image = WindowsApp.Properties.Resources.ex;
            }
            else
            {
                btnExpand.Image = WindowsApp.Properties.Resources.col;
                ribbonControl.Expanded = true;
            }
        }
        private void ribbonTabItem_DClick(object sender, EventArgs e)
        {
            if (ribbonControl.Expanded)
            {
                btnExpand.Image = WindowsApp.Properties.Resources.col;
            }
            else
            {
                btnExpand.Image = WindowsApp.Properties.Resources.ex;
            }
        }

        private void frmFormChuongTrinh_Load(object sender, EventArgs e)
        {
            lblUser.Text = "Xin chào: " + _tk.Username;
            XuLyPhanQuyen();
        }

        private void XuLyPhanQuyen()
        {
            if (_tk.PhanQuyen.ToUpper() == "ADMIN")
            {
                ribbarQLKHGD.Enabled = true;
                ribbarTaoTKB.Enabled = true;
                btnQLTaiKhoan.Enabled = true;
            }
        }

        private void btnQLMonHoc_Click(object sender, EventArgs e)
        {
            frmQLMonHoc frm = new frmQLMonHoc();
            frm._tk = this._tk;
            XuLyChildreForm(frm);
        }
        void XuLyChildreForm(Form frm)
        {
            while (this.MdiChildren.Length > 0)
                this.MdiChildren[0].Close();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnQLGiaoVien_Click(object sender, EventArgs e)
        {
            frmQLGiaoVien frm = new frmQLGiaoVien();
            frm._tk = this._tk;
            XuLyChildreForm(frm);
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnQLTaiKhoan_Click(object sender, EventArgs e)
        {
            frmQLTaiKhoan frm = new frmQLTaiKhoan();
            XuLyChildreForm(frm);
        }

        private void btnQLLopHoc_Click(object sender, EventArgs e)
        {
            frmQLLopHoc frm = new frmQLLopHoc();
            frm._tk = this._tk;
            XuLyChildreForm(frm);
        }

        private void btnTaoTKBDeNghi_Click(object sender, EventArgs e)
        {
            frmTaoTKBDN frm = new frmTaoTKBDN();
            XuLyChildreForm(frm);
        }

        private void btnQLKeHoachGD_Click(object sender, EventArgs e)
        {
            FrmQLKeHoachGiangDay frm = new FrmQLKeHoachGiangDay();
            XuLyChildreForm(frm);
        }


    }
}
